home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / sun / font / GraphicComponent.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  5.3 KB  |  247 lines

  1. package sun.font;
  2.  
  3. import java.awt.Graphics2D;
  4. import java.awt.Rectangle;
  5. import java.awt.Shape;
  6. import java.awt.font.FontRenderContext;
  7. import java.awt.font.GlyphJustificationInfo;
  8. import java.awt.font.GraphicAttribute;
  9. import java.awt.geom.AffineTransform;
  10. import java.awt.geom.GeneralPath;
  11. import java.awt.geom.Rectangle2D;
  12.  
  13. public final class GraphicComponent implements TextLineComponent, Decoration.Label {
  14.    public static final float GRAPHIC_LEADING = 2.0F;
  15.    private GraphicAttribute graphic;
  16.    private int graphicCount;
  17.    private int[] charsLtoV;
  18.    private byte[] levels;
  19.    private Rectangle2D visualBounds = null;
  20.    private float graphicAdvance;
  21.    private AffineTransform baseTx;
  22.    // $FF: renamed from: cm sun.font.CoreMetrics
  23.    private CoreMetrics field_0;
  24.    private Decoration decorator;
  25.  
  26.    public GraphicComponent(GraphicAttribute var1, Decoration var2, int[] var3, byte[] var4, int var5, int var6, AffineTransform var7) {
  27.       if (var6 <= var5) {
  28.          throw new IllegalArgumentException("0 or negative length in GraphicComponent");
  29.       } else {
  30.          this.graphic = var1;
  31.          this.graphicAdvance = var1.getAdvance();
  32.          this.decorator = var2;
  33.          this.field_0 = createCoreMetrics(var1);
  34.          this.baseTx = var7;
  35.          this.initLocalOrdering(var3, var4, var5, var6);
  36.       }
  37.    }
  38.  
  39.    private GraphicComponent(GraphicComponent var1, int var2, int var3, int var4) {
  40.       this.graphic = var1.graphic;
  41.       this.graphicAdvance = var1.graphicAdvance;
  42.       this.decorator = var1.decorator;
  43.       this.field_0 = var1.field_0;
  44.       this.baseTx = var1.baseTx;
  45.       int[] var5 = null;
  46.       byte[] var6 = null;
  47.       if (var4 == 2) {
  48.          var5 = var1.charsLtoV;
  49.          var6 = var1.levels;
  50.       } else {
  51.          if (var4 != 0 && var4 != 1) {
  52.             throw new IllegalArgumentException("Invalid direction flag");
  53.          }
  54.  
  55.          var3 -= var2;
  56.          var2 = 0;
  57.          if (var4 == 1) {
  58.             var5 = new int[var3];
  59.             var6 = new byte[var3];
  60.  
  61.             for(int var7 = 0; var7 < var3; ++var7) {
  62.                var5[var7] = var3 - var7 - 1;
  63.                var6[var7] = 1;
  64.             }
  65.          }
  66.       }
  67.  
  68.       this.initLocalOrdering(var5, var6, var2, var3);
  69.    }
  70.  
  71.    private void initLocalOrdering(int[] var1, byte[] var2, int var3, int var4) {
  72.       this.graphicCount = var4 - var3;
  73.       if (var1 != null && var1.length != this.graphicCount) {
  74.          this.charsLtoV = BidiUtils.createNormalizedMap(var1, var2, var3, var4);
  75.       } else {
  76.          this.charsLtoV = var1;
  77.       }
  78.  
  79.       if (var2 != null && var2.length != this.graphicCount) {
  80.          this.levels = new byte[this.graphicCount];
  81.          System.arraycopy(var2, var3, this.levels, 0, this.graphicCount);
  82.       } else {
  83.          this.levels = var2;
  84.       }
  85.  
  86.    }
  87.  
  88.    public boolean isSimple() {
  89.       return false;
  90.    }
  91.  
  92.    public Rectangle getPixelBounds(FontRenderContext var1, float var2, float var3) {
  93.       throw new InternalError("do not call if isSimple returns false");
  94.    }
  95.  
  96.    public Rectangle2D handleGetVisualBounds() {
  97.       Rectangle2D var1 = this.graphic.getBounds();
  98.       float var2 = (float)var1.getWidth() + this.graphicAdvance * (float)(this.graphicCount - 1);
  99.       return new Rectangle2D.Float((float)var1.getX(), (float)var1.getY(), var2, (float)var1.getHeight());
  100.    }
  101.  
  102.    public CoreMetrics getCoreMetrics() {
  103.       return this.field_0;
  104.    }
  105.  
  106.    public static CoreMetrics createCoreMetrics(GraphicAttribute var0) {
  107.       return new CoreMetrics(var0.getAscent(), var0.getDescent(), 2.0F, var0.getAscent() + var0.getDescent() + 2.0F, var0.getAlignment(), new float[]{0.0F, -var0.getAscent() / 2.0F, -var0.getAscent()}, -var0.getAscent() / 2.0F, var0.getAscent() / 12.0F, var0.getDescent() / 3.0F, var0.getAscent() / 12.0F, 0.0F, 0.0F);
  108.    }
  109.  
  110.    public float getItalicAngle() {
  111.       return 0.0F;
  112.    }
  113.  
  114.    public Rectangle2D getVisualBounds() {
  115.       if (this.visualBounds == null) {
  116.          this.visualBounds = this.decorator.getVisualBounds(this);
  117.       }
  118.  
  119.       Rectangle2D.Float var1 = new Rectangle2D.Float();
  120.       var1.setRect(this.visualBounds);
  121.       return var1;
  122.    }
  123.  
  124.    public Shape handleGetOutline(float var1, float var2) {
  125.       double[] var3 = new double[]{(double)1.0F, (double)0.0F, (double)0.0F, (double)1.0F, (double)var1, (double)var2};
  126.       if (this.graphicCount == 1) {
  127.          AffineTransform var7 = new AffineTransform(var3);
  128.          return this.graphic.getOutline(var7);
  129.       } else {
  130.          GeneralPath var4 = new GeneralPath();
  131.  
  132.          for(int var5 = 0; var5 < this.graphicCount; ++var5) {
  133.             AffineTransform var6 = new AffineTransform(var3);
  134.             var4.append(this.graphic.getOutline(var6), false);
  135.             var3[4] += (double)this.graphicAdvance;
  136.          }
  137.  
  138.          return var4;
  139.       }
  140.    }
  141.  
  142.    public AffineTransform getBaselineTransform() {
  143.       return this.baseTx;
  144.    }
  145.  
  146.    public Shape getOutline(float var1, float var2) {
  147.       return this.decorator.getOutline(this, var1, var2);
  148.    }
  149.  
  150.    public void handleDraw(Graphics2D var1, float var2, float var3) {
  151.       for(int var4 = 0; var4 < this.graphicCount; ++var4) {
  152.          this.graphic.draw(var1, var2, var3);
  153.          var2 += this.graphicAdvance;
  154.       }
  155.  
  156.    }
  157.  
  158.    public void draw(Graphics2D var1, float var2, float var3) {
  159.       this.decorator.drawTextAndDecorations(this, var1, var2, var3);
  160.    }
  161.  
  162.    public Rectangle2D getCharVisualBounds(int var1) {
  163.       return this.decorator.getCharVisualBounds(this, var1);
  164.    }
  165.  
  166.    public int getNumCharacters() {
  167.       return this.graphicCount;
  168.    }
  169.  
  170.    public float getCharX(int var1) {
  171.       int var2 = this.charsLtoV == null ? var1 : this.charsLtoV[var1];
  172.       return this.graphicAdvance * (float)var2;
  173.    }
  174.  
  175.    public float getCharY(int var1) {
  176.       return 0.0F;
  177.    }
  178.  
  179.    public float getCharAdvance(int var1) {
  180.       return this.graphicAdvance;
  181.    }
  182.  
  183.    public boolean caretAtOffsetIsValid(int var1) {
  184.       return true;
  185.    }
  186.  
  187.    public Rectangle2D handleGetCharVisualBounds(int var1) {
  188.       Rectangle2D var2 = this.graphic.getBounds();
  189.       Rectangle2D.Float var3 = new Rectangle2D.Float();
  190.       var3.setRect(var2);
  191.       var3.x += this.graphicAdvance * (float)var1;
  192.       return var3;
  193.    }
  194.  
  195.    public int getLineBreakIndex(int var1, float var2) {
  196.       int var3 = (int)(var2 / this.graphicAdvance);
  197.       if (var3 > this.graphicCount - var1) {
  198.          var3 = this.graphicCount - var1;
  199.       }
  200.  
  201.       return var3;
  202.    }
  203.  
  204.    public float getAdvanceBetween(int var1, int var2) {
  205.       return this.graphicAdvance * (float)(var2 - var1);
  206.    }
  207.  
  208.    public Rectangle2D getLogicalBounds() {
  209.       float var1 = 0.0F;
  210.       float var2 = -this.field_0.ascent;
  211.       float var3 = this.graphicAdvance * (float)this.graphicCount;
  212.       float var4 = this.field_0.descent - var2;
  213.       return new Rectangle2D.Float(var1, var2, var3, var4);
  214.    }
  215.  
  216.    public float getAdvance() {
  217.       return this.graphicAdvance * (float)this.graphicCount;
  218.    }
  219.  
  220.    public Rectangle2D getItalicBounds() {
  221.       return this.getLogicalBounds();
  222.    }
  223.  
  224.    public TextLineComponent getSubset(int var1, int var2, int var3) {
  225.       if (var1 >= 0 && var2 <= this.graphicCount && var1 < var2) {
  226.          return var1 == 0 && var2 == this.graphicCount && var3 == 2 ? this : new GraphicComponent(this, var1, var2, var3);
  227.       } else {
  228.          throw new IllegalArgumentException("Invalid range.  start=" + var1 + "; limit=" + var2);
  229.       }
  230.    }
  231.  
  232.    public String toString() {
  233.       return "[graphic=" + this.graphic + ":count=" + this.getNumCharacters() + "]";
  234.    }
  235.  
  236.    public int getNumJustificationInfos() {
  237.       return 0;
  238.    }
  239.  
  240.    public void getJustificationInfos(GlyphJustificationInfo[] var1, int var2, int var3, int var4) {
  241.    }
  242.  
  243.    public TextLineComponent applyJustificationDeltas(float[] var1, int var2, boolean[] var3) {
  244.       return this;
  245.    }
  246. }
  247.